﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MvCameraControl;

namespace CLVisionCameraControl
{
    //基础相机接口，定义通用方法
    public interface ICLVisionCamera
    {
        event Action<Bitmap> EventGrabBackBitmapImage;

        //图像显示句柄
        IntPtr HWnd { get; set; }

        //相机的参数信息
        ICLVisionCameraInfo CLVisionCameraInfo { get; set; }

        bool IsOpen { get; set; }
        Bitmap OutBMPImage { get; set; }


        void OpenDeviceBySerialNumber(string serialNumber, out int ErrorCode, out string ErrorText);
        void OpenDeviceByUserDefinedName(string userDefinedName, out int ErrorCode, out string ErrorText);
        void OpenDeviceByIp(string cameraIp, string netExport, out int ErrorCode, out string ErrorText);

        void CloseDevice(out int ErrorCode, out string ErrorText);


        void StartGrab(out int ErrorCode, out string ErrorText);

        void StopGrab(out int ErrorCode, out string ErrorText);

        void SetAcquisitionContinuesMode(out int ErrorCode, out string ErrorText);
        void TriggerSoftwareOnce(out int ErrorCode, out string ErrorText);

        // ch:触发源选择:0 - Line0; | en:Trigger source select:0 - Line0;
        //           1 - Line1;
        //           2 - Line2;
        //           3 - Line3;
        //           4 - Counter;
        //           7 - Software;
        void SetTriggerSource(EnumTriggerSource enumTriggerSource, out int ErrorCode, out string ErrorText);
        void SetTriggerMode(EnumTriggerMode enumTriggerMode, out int ErrorCode, out string ErrorText);

        void GetTriggerMode(out EnumTriggerMode enumTriggerMode, out int ErrorCode, out string ErrorText);
        void GetTriggerSource(out EnumTriggerSource enumTriggerSource, out int ErrorCode, out string ErrorText);


        void SetParamExposure(float exposureTime, out int ErrorCode, out string ErrorText);
        void SetParamGain(float gain, out int ErrorCode, out string ErrorText);
        void SetParamFrameRate(float frameRate, out int ErrorCode, out string ErrorText);
        void SetParamPixelFormat(EnumPixelFormat pixelFormat, out int ErrorCode, out string ErrorText);


        void GetParamExposure(out float exposureTime, out int ErrorCode, out string ErrorText);
        void GetParamGain(out float gain, out int ErrorCode, out string ErrorText);
        void GetParamFrameRate(out float frameRate, out int ErrorCode, out string ErrorText);
        void GetParamPixelFormat(out EnumPixelFormat enumPixelFormat, out int ErrorCode, out string ErrorText);

        void FeatureLoad(string filePath, out int ErrorCode, out string ErrorText);

        void FeatureSave(string filePath, out int ErrorCode, out string ErrorText);

        Bitmap AcquireOneFrameImage(out int ErrorCode, out string ErrorText);
        void AcquireImageContinuous(IntPtr _handle, out int ErrorCode, out string ErrorText);
        void SetParamValueByFieldName(string fieldName, object value, out int ErrorCode, out string ErrorText);
        void GetParamValueByFieldName(string fieldName, out object value, out int ErrorCode, out string ErrorText);
    
        List<string> GetParamFieldNames(out int ErrorCode, out string ErrorText);
        List<ICLVisionCameraParameterStruct> GetParamFields(out int ErrorCode, out string ErrorText);
    }
}
